const mysql = require('mysql');
const dbConfig = require('../config').dbConfig;

function http(sql, params = [], conConfig = {}) {
    return new Promise((resolve, reject) => {
        let con = mysql.createConnection({
            ...dbConfig,
            ...conConfig
        });
        con.query(sql, params, (error, results) => {
            con.end();
            if (error) reject(error);
            else resolve(results);
        });
    });
}


module.exports = http;